package c2.cross.server.configuration;

import c2.advanced.server.configuration.AdvPostProcessUtils;
import c2.advanced.server.configuration.AdvServerEnv;
import c2.cross.server.CrossServerApplication;
import cp.server.template.adv.AdvEnvPostProcessor;
import cp.server.template.adv.AdvLauncher;
import cp.solution.business.game.boot.AdvancedSrvBootstrap;
import cp.solution.business.game.boot.CrossSrvBootstrap;
import cp.solution.business.game.conf.CrossConfigEntity;
import cp.solution.define.HardRule;
import cp.solution.manage.PrimaryClient;
import org.springframework.core.Ordered;
import org.springframework.core.annotation.Order;

import java.util.Map;

@Order(Ordered.LOWEST_PRECEDENCE)
public class CrossServerEnvPostProcessor extends AdvEnvPostProcessor<CrossConfigEntity> {

    @Override
    protected String getSecretProp() {
        return AdvServerEnv.getSecretProp();
    }

    @Override
    protected String getConsoleBaseUriProp() {
        return AdvServerEnv.getConsoleBaseUriProp();
    }

    @Override
    protected String getApiHostTypeProp() {
        return AdvServerEnv.getApiHostTypeProp();
    }

    @Override
    protected String getCodeProp() {
        return AdvServerEnv.getCodeProp();
    }

    @Override
    protected String getExcelPathProp() {
        return AdvServerEnv.getExcelPathProp();
    }

    @Override
    protected String getStartCmdCode() {
        return CrossServerApplication.cmd.code;
    }

    @Override
    protected AdvLauncher getLauncher() {
        return CrossServerApplication.launcher;
    }

    @Override
    protected AdvancedSrvBootstrap<CrossConfigEntity> loadBootstrap(PrimaryClient pc, String code) {
        CrossSrvBootstrap bs = pc.console.crossConfig.bootstrap(code);
        return bs;
    }

    @Override
    protected void handlePropertySource(Map<String, Object> map, String code, AdvancedSrvBootstrap<CrossConfigEntity> bootstrap) {
        String s = AdvPostProcessUtils.hps(map, bootstrap, HardRule.getMongoDatabaseNameOfCross(code));
        print(s);
    }

}
